package com.mate.cloud.order.controller;

import com.mate.cloud.common.response.BaseResponse;
import com.mate.cloud.common.web.controller.AdminBaseController;
import com.mate.cloud.order.entity.Order;
import com.mate.cloud.order.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * MessageModel：集群模式；广播模式
 * ConsumeMode：顺序消费；无序消费
 */
@RestController
@RequestMapping("/orders")
public class OrderController extends AdminBaseController {

    @Resource
    private OrderService orderService;

    /**
     * 创建订单接口
     */
    @PostMapping("/createOrder")
    public BaseResponse<Order> createOrder(
            @RequestParam String userId,
            @RequestParam String productId,
            @RequestParam Integer quantity) {

        return successBodyResponse(orderService.createOrder(userId, productId, quantity));
    }

}
